<?php

namespace app\admin\model;

use think\Model;

class Zztemplate extends Model
{
    // 表名
    protected $name = 'zztemplate';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'cate_text',
        'toobject_text',
        'use_text'
    ];
    

    
    public function getCateList()
    {
        return ['4' => __('Cate 4'),'3' => __('Cate 3'),'2' => __('Cate 2'),'1' => __('Cate 1')];
    }     

    public function getToobjectList()
    {
        return ['3' => __('Toobject 3'),'2' => __('Toobject 2'),'1' => __('Toobject 1')];
    }     

    public function getUseList()
    {
        return ['2' => __('Use 2'),'1' => __('Use 1')];
    }     


    public function getCateTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['cate'];
        $list = $this->getCateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getToobjectTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['toobject'];
        $list = $this->getToobjectList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getUseTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['use'];
        $list = $this->getUseList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
